$('#top').load('top.html');
$('#bottom').load('bottom.html');

$('.btn').click(() => {
    const nick = $('#nickname').val()
    const name = $('#username').val()
    const pwd = $('#password').val()

    var data = {
        nickname: nick,
        username: name,
        password: pwd
    }

    for (var i in data) {
        if (!data[i]) return alert('请完整填写')
    }

    $.post('http://localhost:8080/php/register.php', data, res => {
        console.log(res);
        if (res.code !== 1) return alert(res.message)
        alert(res.message)
        window.location.href = './login.html'
    }, 'json')
})